package com.example.stock_trading.tmp;

import org.junit.Test;

/**
 * @program: stock_trading
 * @description:
 * @author: zhanghz001
 * @create: 2021-04-13 10:48
 **/
public class TmpTest {
    @Test
    public void test() {
        double max;
        double min;
        double now;
        String stock = "";
        //   stock = "股票1";
        // //股票1
        // max = 61.39;
        // min = 31.8;
        // data(stock, max, min);
        //
        // //股票600526
        // stock = "股票600526";
        // max = 10;
        // min = 4.03;
        // data(stock, max, min);
        //
        // //股票 660793
        // stock = "660793";
        // max = 21.26;
        // min = 8;
        // data(stock, max, min);
        //
        // //股票 603222
        // stock = "603222";
        // max = 22.98;
        // min = 8.83;
        // data(stock, max, min);
        //
        // stock = "603222";
        // max = 22.17;
        // min = 13.45;
        // data(stock, max, min);
        //
        // //股票 10倍
        // max = 10;
        // min = 1;
        // data(stock, max, min);
        //
        // stock = "美邦服饰";
        // max = 2.18;
        // min = 1.40;
        // data(stock, max, min);
        //
        // stock = "美邦服饰";
        // max = 4.13;
        // min = 1.51;
        // data(stock, max, min);
        //
        stock = "舒华股份";
        max = 20.75;
        min = 11.69;
        now = 14.55;
        data(stock, max, min, now);
        
        stock = "永茂泰";
        max = 38.54;
        min = 20.69;
        now = 27;
        data(stock, max, min, now);
    }
    
    // 股票涨幅的公式,这样就可以判断买点了
    public void data(String stock, double max, double min, double now) {
        double rocket_rate = max / min - 1;
        System.out.println(stock + " 上涨幅度: " + rocket_rate);
        // 
        double now_down_rate = 1 - now / max;
        System.out.println(stock + " 实际下跌幅度: " + now_down_rate);
        double down_rate = (rocket_rate) / (2 + 2 * rocket_rate);
        System.out.println(stock + " 买入下跌幅度: " + down_rate);
        double buy_price = max * (1 - down_rate);
        System.out.println(stock + " 买入价钱: " + buy_price);
        
    }
    
}
